package com.rwhansen.humidor;

import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.awt.Toolkit;

public class PickACigarForMe {
	
	public static Database cigarDatabase;
	public static Database humidorDatabase;
	public static Database ratingsDatabase;

	JFrame frmStats;

	public PickACigarForMe() {
		
		String humidorDatabaseFileName = Database.HUMIDOR_DB_FILENAME;
		humidorDatabase = new Database(humidorDatabaseFileName);
		File file2 = new File(humidorDatabaseFileName);
		boolean exists2 = file2.exists();
		if (exists2) {
			humidorDatabase = Database.readDatabase(humidorDatabaseFileName);
		}

		
		frmStats = new JFrame();
		frmStats.setIconImage(Toolkit.getDefaultToolkit().getImage(PickACigarForMe.class.getResource("/com/rwhansen/humidor/favicon.ico")));
		frmStats.setFont(new Font("GodOfWar", Font.PLAIN, 12));
		frmStats.setTitle("Random Cigar");
		frmStats.setAlwaysOnTop(true);
		frmStats.setBounds(100, 100, 607, 144);
		frmStats.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		
		JPanel panel = new JPanel();
		frmStats.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel lblCreatedByRobert = new JLabel("Are you in the mood for a");
		lblCreatedByRobert.setFont(new Font("GodOfWar", Font.PLAIN, 13));
		lblCreatedByRobert.setHorizontalAlignment(SwingConstants.CENTER);
		lblCreatedByRobert.setBounds(12, 11, 583, 16);
		panel.add(lblCreatedByRobert);
		
		JLabel label = new JLabel(humidorDatabase.getRandomCigar() + " ?");
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setFont(new Font("GodOfWar", Font.PLAIN, 13));
		label.setBounds(12, 38, 583, 16);
		panel.add(label);
		
		JButton btnPickAgain = new JButton("Pick Again");
		btnPickAgain.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				//TODO: Refresh line two
			}
		});
		btnPickAgain.setFont(new Font("GodOfWar", Font.PLAIN, 13));
		btnPickAgain.setBounds(67, 65, 201, 29);
		btnPickAgain.setEnabled(false);
		panel.add(btnPickAgain);
		
		JButton btnClose = new JButton("Close");
		btnClose.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frmStats.setVisible(false);
			}
		});
		btnClose.setFont(new Font("GodOfWar", Font.PLAIN, 13));
		btnClose.setBounds(331, 65, 201, 29);
		panel.add(btnClose);
		
	}
}
